package com.xjoyt.pay.master.po;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xjoyt.pay.constants.DateConstant;

/**
 * 退款
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_refund")
public class Refund {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	@Column(name = "refund_id", length = 36)
	public String id;

	/**
	 * 订单
	 */
	@ManyToOne(targetEntity = Order.class, cascade = {})
	@JoinColumn(name = "order_id", foreignKey = @ForeignKey(name = "none"))
	public Order order;

	/**
	 * 系统流水号
	 */
	@Column(name = "no", length = 50)
	public String no;

	/**
	 * 上游流水号
	 */
	@Column(name = "trade_no", length = 255)
	public String tradeNo;

	/**
	 * 商户流水号
	 */
	@Column(name = "out_trade_no", length = 255)
	public String outTradeNo;

	/**
	 * 金额(分)
	 */
	@Column(name = "money")
	public Long money;

	/**
	 * 生成状态(NULL：未生成订单，true：订单生成成功，false：订单生成失败)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_success")
	public Boolean success;

	/**
	 * 生成日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;

	/**
	 * 是否退款(true：成功，false：不成功)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_done")
	public Boolean done;

	/**
	 * 退款日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "done_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date doneDate;

	/**
	 * 下游通知地址
	 */
	@Column(name = "notify_url", length = 255)
	public String notifyUrl;

	/**
	 * 是否通知下游(NULL：未通知单，true：通知成功，false：通知失败)
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_notify")
	public Boolean notify;

	/**
	 * 通知日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "notify_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date notifyDate;

	/**
	 * 适配器退款地址
	 */
	@Column(name = "`url`", length = 255)
	public String url;

	/**
	 * 回调地址
	 */
	@Column(name = "callback_url", length = 255)
	public String callbackUrl;

	/**
	 * 消息
	 */
	@Column(name = "message", length = 255)
	public String message;

}
